﻿<?php $this->load->view('inc/header'); ?>
<!--c_blog1-->

<div class="grid_12" style="padding-top:10px; background-color:#292929;">
  <div class="grid_4 omega">
    <div style="-moz-border-radius-topleft: 4px;
-moz-border-radius-topright: 4px;
-moz-border-radius-bottomright: 4px;
-moz-border-radius-bottomleft: 4px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px; background:#F4F4F4; padding:3px;">
      <?php
	$session_login = $this->session->userdata('is_logged_in');
	if($session_login)
	{
		$this->db->where('member_id',$this->session->userdata('member_id'));
		$query = $this->db->get('membership');
		foreach($query->result() as $rows){
			$username = $rows->username;
			$firstname = $rows->firstname;
			$lastname = $rows->lastname;
			$nickname = $rows->nickname;
			$member_display = $rows->member_display;
		}
 ?>
      <div id="avatar" style="position:relative;">
        <?php
		if($member_display)
		{
    ?>
        <img src="<?=base_url()?>km_resource/member_display/<?=$member_display?>" width="60" height="60"/>
        <?php
		}
		else
		{
	?>
        <img src="<?=base_url()?>km_resource/member_display/null.png" width="60" height="60"/>
        <?php
		}
	?>
        <div id="menu_users" style="position:absolute; left:100px; top:0px;">
          <div id="nickname" style="font-size:small; font-family:Arial, Helvetica, sans-serif;">
            <p>
              <?=$firstname?>
              <?=$lastname?>
            </p>
            <p>
              <?=$nickname?>
            </p>
            <p>
              <a href="<?=base_url()?>logout" style="border:none; background: #ED0C66; -moz-border-radius: 4px; -webkit-border-radius: 4px; padding:2px;
        color:#FFFFFF;
    box-shadow: 0 1px 0 white;
	-moz-box-shadow: 0 1px 0 white;
	-webkit-box-shadow: 0 1px 0 white;
	text-decoration:none;">Logout</a></p>
          </div>
        </div>
      </div>
      <?php
	}
	else
	{
?>
      <div id="menu_guest">Guest! ,Please <a href="<?=base_url()?>logon/signup">Register</a> or Logon to access this section.</div>
      <?php
	}
?>
    </div>
  </div>
  <div class="grid_7">
    <div style="-moz-border-radius-topleft: 4px;
-moz-border-radius-topright: 4px;
-moz-border-radius-bottomright: 4px;
-moz-border-radius-bottomleft: 4px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px; background:#B0B0B0; padding:3px;"><?php if($this->session->userdata('is_logged_in') == true){ ?><a href="<?=base_url()?>blog/read/<?=$nickname?>"><img src="<?=base_url()?>images/graphic/view_my_blog.png"/></a><?php } ?>&nbsp;<a href="<?=base_url()?>blog/all_blog/"><img src="<?=base_url()?>images/graphic/all_blog_but.png"/></a></div>
  </div>
</div>
<div class="clear"></div>
<!--end c_blog1-->
<!--c_blog2-->
<div class="grid_12" style="padding-top:15px; background-color:#292929; padding-bottom:15px;">
  <div class="grid_12 alpha" id="panel_top">
    <div style="padding-left:15px; padding-top:15px; color:#000000; font-weight:bold; text-shadow: 1px 1px 1px #ffffff;
filter: dropshadow(color=#ffffff, offx=1, offy=1);">KM Categoty.</div>
  </div>
  <div class="grid_12 alpha" id="panel_middle">
    <div style="padding-left:25px; padding-top:5px; color:#000000; font-size:small; color:#333333;">
      <?php
			$inirows = 0;
			$query = $this->db->get('blog_category');
			echo"<table border=\"0\"  cellspacing=\"1\" cellpadding=\"1\"><tr>";	
			foreach($query->result() as $rows){
				$b_category_id = $rows->b_category_id;
				$category_name = $rows->category_name;
				$category_description = $rows->category_description;
				$category_display = $rows->category_display;
				
				$inirows++;
				echo "<td width=\"500\">";
		?>
      <div id="blog_cat" style="position:relative; padding:5px;">
        <div id="display_cat"><a href="<?=base_url()?>blog/category/<?=$b_category_id?>"><img src="<?=base_url()?>km_resource/blog_category/<?=$category_display?>"/></a></div>
        <div id="name_cat" style="position:absolute; left:80px; top:5px;"><img src="<?=base_url()?>images/right.png" style="vertical-align:middle;"/><a href="<?=base_url()?>blog/category/<?=$b_category_id?>"><?=$category_name?>
          </a></div>
        <div id="desc_cat"  style="position:absolute; left:80px; top:25px; font-size:11px; width:180px;">
          <?=character_limiter($category_description,80)?>
        </div>
      </div>
      <?php
		echo "</td>";
		if(($inirows)%3==0)
		{
		echo "</tr>";
		}
		else
		{
		echo "<td>";
		}	
	}
	echo "</tr></table>";
	?>
    </div>
  </div>
  <div class="grid_12 alpha" id="panel_bottom"> </div>
</div>
<div class="clear"></div>
<!--end c_blog2-->

<div class="grid_12" style="background:#999999;">
	<div class="grid_4 alpha" style="margin-top:8px;">
    <div id="p-top"></div>
    <div id="p-middle">
    <div id="display_latest">
<ol  style="list-style:none;">
<?php
			$this->db->limit(3);
			$this->db->order_by('blog_id','desc');
			$this->db->join('membership','membership.member_id=blog.blog_author');
			$lastest_query = $this->db->get('blog');
			
			foreach($lastest_query->result() as $l_rows){
		?>
<li style="padding-bottom:10px;">
  <div id="author_avatar_lastest" style="position:relative; padding:2px;">
    <?php
        	if($l_rows->member_display == NULL)
            {
        ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/null.png" width="30" height="30"/></div>
    <?php
            }
             else
            {
         ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/<?=$l_rows->member_display?>" width="39" height="35"/></div>
    <?php
            }
    ?>
    <!--  entry desc -->
    <div id="entry_desc_lastest" style="position:absolute; left:45px; top:1px; font-size:11px;">
    	<a href="<?=base_url()?>blog/<?=$l_rows->nickname?>/entry/<?=$l_rows->blog_id?>"><?=character_limiter($l_rows->blog_entry_name,80)?></a>
    </div>
    <!--  date create -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:14px; font-size:10px; color:#666666;">
    	Date: <?=$l_rows->blog_create_date?>
    </div>
    <!--  author -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:26px; font-size:10px; color:#333333;">
    	By: <?=$l_rows->firstname?>&nbsp;<?=$l_rows->lastname?>&nbsp;(<?=$l_rows->nickname?>)
    </div>
  </div>
</li>
<?php
		}
		?>
</o>
</div>
</div>
<div id="p-bottom">Lastest Blog.</div>
</div>
<!-- close div latest bllog -->

<div class="grid_4" style="margin-top:8px;">
  <div id="p-top"></div>
  <div id="p-middle">
  	<div id="visitors_display">
<ol  style="list-style:none;">
<?php
			
			$visitors_query = $this->db->query('select blog_views_log.blog_id,sum(blog_views_log.view_counts) as vv, membership.member_display, blog.blog_entry_name, blog.blog_create_date,membership.firstname, membership.lastname, membership.nickname from blog_views_log, membership, blog where (blog_views_log.member_id=membership.member_id) and (blog_views_log.blog_id=blog.blog_id) group by blog_views_log.blog_id order by vv desc limit 3');
			
			foreach($visitors_query->result() as $v_rows){
		?>
<li style="padding-bottom:10px;">
   <div id="author_avatar_lastest" style="position:relative; padding:2px;">
    <?php
        	if($v_rows->member_display == NULL)
            {
        ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/null.png" width="30" height="30"/></div>
    <?php
            }
             else
            {
         ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/<?=$v_rows->member_display?>" width="39" height="35"/></div>
    <?php
            }
    ?>
    <!--  entry desc -->
    <div id="entry_desc_lastest" style="position:absolute; left:45px; top:1px; font-size:11px;">
    	<a href="<?=base_url()?>blog/<?=$v_rows->nickname?>/entry/<?=$v_rows->blog_id?>"><?=character_limiter($v_rows->blog_entry_name,80)?></a>
    </div>
    <!--  date create -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:14px; font-size:10px; color:#666666;">
    	Date: <?=$v_rows->blog_create_date?>
    </div>
    <!--  author -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:26px; font-size:10px; color:#333333;">
    	By: <?=$v_rows->firstname?>&nbsp;<?=$v_rows->lastname?>&nbsp;(<?=$v_rows->nickname?>)
    </div>
     <div id="entry_date_lastest" style="position:absolute; right:5px; top:5px; font-size:10px; color:#333333; background:#CFF8A3; padding:2px; border: thin groove #669900;">
    	Hits: <?=$v_rows->vv?>
    </div>
  </div>
</li>
<?php
		}
		?>
</o>
</div>
  </div>
  <div id="p-bottom">Many Visitors.</div>
</div>
<div class="grid_4 omega" style="margin-top:8px;">
  <div id="p-top"></div>
  <div id="p-middle">
  	<div id="pop_display">
<ol  style="list-style:none;">
<?php
			
			$pop_query = $this->db->query('select blog_vote.blog_id,sum(blog_vote.like_vote) as pop, blog_vote.member_id, membership.member_display, blog.blog_entry_name, blog.blog_create_date,membership.firstname, membership.lastname, membership.nickname from blog_vote, membership, blog where (blog_vote.member_id=membership.member_id) and (blog_vote.blog_id=blog.blog_id) group by blog_id order by pop desc limit 3');
			
			foreach($pop_query->result() as $p_rows){
		?>
<li style="padding-bottom:10px;">
   <div id="author_avatar_lastest" style="position:relative; padding:2px;">
    <?php
        	if($p_rows->member_display == NULL)
            {
        ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/null.png" width="30" height="30"/></div>
    <?php
            }
             else
            {
         ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/<?=$p_rows->member_display?>" width="39" height="35"/></div>
    <?php
            }
    ?>
    <!--  entry desc -->
    <div id="entry_desc_lastest" style="position:absolute; left:45px; top:1px; font-size:11px;">
    	<a href="<?=base_url()?>blog/<?=$p_rows->nickname?>/entry/<?=$p_rows->blog_id?>"><?=character_limiter($p_rows->blog_entry_name,80)?></a>
    </div>
    <!--  date create -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:14px; font-size:10px; color:#666666;">
    	Date: <?=$p_rows->blog_create_date?>
    </div>
    <!--  author -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:26px; font-size:10px; color:#333333;">
    	By: <?=$p_rows->firstname?>&nbsp;<?=$p_rows->lastname?>&nbsp;(<?=$p_rows->nickname?>)
    </div>
     <div id="entry_date_lastest" style="position:absolute; right:5px; top:5px; font-size:10px; color:#333333; background:#35BAEC; padding:2px; border: thin groove #006699;">
    	Vote: <?=$p_rows->pop?>
    </div>
  </div>
</li>
<?php
		}
		?>
</o>
</div>
  </div>
  <div id="p-bottom">Popular Vote.</div>
</div>
<div class="clear"></div>
<div class="grid_4 alpha" style="margin-top:8px;">
  <div id="p-top"></div>
  <div id="p-middle">
  	<div id="top_comment">
    	<ol  style="list-style:none;">
<?php
			
			$top_comment = $this->db->query('select membership.nickname, membership.firstname, membership.lastname, membership.member_display, count(*) as c from blog_comment,membership where (blog_comment.member_id=membership.member_id) group by blog_comment.member_id order by c desc limit 3');
			
			foreach($top_comment->result() as $c_rows){
		?>
<li>
  <div id="author_avatar_lastest" style="position:relative; padding:2px;">
    <?php
        	if($c_rows->member_display == NULL)
            {
        ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/null.png" width="30" height="30"/></div>
    <?php
            }
             else
            {
         ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/<?=$c_rows->member_display?>" width="39" height="35"/></div>
    <?php
            }
    ?>
    <!--  entry desc -->
    <div id="author_top" style="position:absolute; left:45px; top:1px; font-size:11px;">
    	<?=$c_rows->firstname?>&nbsp;<?=$c_rows->lastname?>&nbsp;(<?=$c_rows->nickname?>)
    </div>
    <!--  date create -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:3px; border-bottom:thin groove #999999; width:200px;">&nbsp;
    </div>
    <!--  author -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:26px; font-size:10px; color:#1A9FC6;">
    	Count: (<?=$c_rows->c?>) 
    </div>
  </div>
</li>
<?php
		}
		?>
</o>
    </div>
  </div>
  <div id="p-bottom">Top Comment.</div>
</div>
<div class="grid_4" style="margin-top:8px;">
  <div id="p-top"></div>
  <div id="p-middle">
  	<div id="display_random">
<ol  style="list-style:none;">
<?php
			$this->db->limit(3);
			$this->db->order_by('blog_id','random');
			$this->db->join('membership','membership.member_id=blog.blog_author');
			$random_query = $this->db->get('blog');
			
			foreach($random_query->result() as $r_rows){
		?>
<li style="padding-bottom:10px;">
  <div id="author_avatar_lastest" style="position:relative; padding:2px;">
    <?php
        	if($r_rows->member_display == NULL)
            {
        ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/null.png" width="30" height="30"/></div>
    <?php
            }
             else
            {
         ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/<?=$r_rows->member_display?>" width="39" height="35"/></div>
    <?php
            }
    ?>
    <!--  entry desc -->
    <div id="entry_desc_lastest" style="position:absolute; left:45px; top:1px; font-size:11px;">
    	<a href="<?=base_url()?>blog/<?=$r_rows->nickname?>/entry/<?=$r_rows->blog_id?>"><?=character_limiter($r_rows->blog_entry_name,80)?></a>
    </div>
    <!--  date create -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:14px; font-size:10px; color:#666666;">
    	Date: <?=$r_rows->blog_create_date?>
    </div>
    <!--  author -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:26px; font-size:10px; color:#333333;">
    	By: <?=$r_rows->firstname?>&nbsp;<?=$r_rows->lastname?>&nbsp;(<?=$r_rows->nickname?>)
    </div>
  </div>
</li>
<?php
		}
		?>
</o>
</div>
  </div>
  <div id="p-bottom">Random Blog.</div>
</div>
<div class="grid_4 omega" style="margin-top:8px;">
  <div id="p-top"></div>
  <div id="p-middle">
  	<div id="top_blog">
    	<ol  style="list-style:none;">
<?php
			
			$top_blog_query = $this->db->query('select nickname,firstname,lastname,member_display,count(*) as c from blog,membership where (blog.blog_author=membership.member_id) group by blog_author order by c desc limit 3');
			
			foreach($top_blog_query->result() as $t_rows){
		?>
<li>
  <div id="author_avatar_lastest" style="position:relative; padding:2px;">
    <?php
        	if($t_rows->member_display == NULL)
            {
        ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/null.png" width="30" height="30"/></div>
    <?php
            }
             else
            {
         ?>
    <div id="avatar"><img src="<?=base_url()?>km_resource/member_display/<?=$t_rows->member_display?>" width="39" height="35"/></div>
    <?php
            }
    ?>
    <!--  entry desc -->
    <div id="author_top" style="position:absolute; left:45px; top:1px; font-size:11px;">
    	<?=$t_rows->firstname?>&nbsp;<?=$t_rows->lastname?>&nbsp;(<?=$t_rows->nickname?>)
    </div>
    <!--  date create -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:3px; border-bottom:thin groove #999999; width:200px;">&nbsp;
    </div>
    <!--  author -->
    <div id="entry_date_lastest" style="position:absolute; left:45px; top:26px; font-size:10px; color:#1A9FC6;">
    	Count: (<?=$t_rows->c?>) 
    </div>
  </div>
</li>
<?php
		}
		?>
</o>
    </div>
  </div>
  <div id="p-bottom">Top Blogers.</div>
</div>
</div>
<div class="clear"></div>
<?php $this->load->view('inc/footer'); ?>
